use std::io;

fn main() {
    println!("Hello, world!");

    let a = [1, 2, 3, 4, 5];
    for element in a {
        println!("{}", element);
    }

    // let mut outer_count = 0;

    for outer_count in 0..2 {
        println!("Outer loop: outer_count is {}", outer_count);

        let mut inner_count = 0;
        'inner: loop {
            println!("Inner loop: inner_count is {}", inner_count);
            if inner_count == 3 {
                println!("break Inner loop");
                break 'inner;
            }
            inner_count += 1;
        }

        // outer_count += 1;
    }

    // println!("result: {}", result);
}

fn plus_one(x: u32) -> u32 {
    println!("plus_one: input {}", x);
    x + 1
}

fn old_func() {
    let guess: u32 = "42".parse().expect("Invalid number!");
    println!("guess: {}", guess);

    let x = 2.0;
    let y: f32 = 3.0;
    println!("x: {}, y: {}", x, y);

    // addition
    let sum = 5 + 10;
    // subtraction
    let difference = 95.5 - 4.3;
    // multiplication
    let product = 4 * 30;
    // division
    let quotient = 56.7 / 32.2;
    let floored = 2 / 3; // Results in 0
                         // remainder
    let remainder = 43 % 5;

    println!(
        "sum: {}, difference: {}, product: {}, quotient: {}, floored: {}, remainder: {}",
        sum, difference, product, quotient, floored, remainder
    );

    let t = true;
    let f: bool = false;
    println!("t: {}, f: {}", t, f);

    let c = 'z';
    let z = 'ℤ';
    let heart_eyed_cat = '😻';
    println!("c: {}, z: {}, heart_eyed_cat: {}", c, z, heart_eyed_cat);

    let tup: (i32, f64, u8) = (500, 6.4, 1);
    // let (x, y, z) = tup;
    println!("tup: {}, {}, {}", tup.0, tup.1, tup.2);

    let a = [1, 2, 3, 4, 5];
    let b = [3; 5];
    let months = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December",
    ];
    println!("a.1: {}", a[1]);
    println!("b.1: {}", b[1]);
    println!("months.1: {}", months[1]);

    println!("Please enter an array index:");
    let mut index = String::new();
    io::stdin()
        .read_line(&mut index)
        .expect("Failed to read array index");

    let index: usize = index.trim().parse().expect("Failed to parse");
    println!("index: {}", index);
    println!("months[{}]: {}", index, months[index]);
}
